﻿using System;
using System.Collections.Generic;

namespace BookStoreLib.Dal
{
    /// <summary>
    /// Base class for Data access layer
    /// </summary>
    /// <typeparam name="T">Entity type</typeparam>
    abstract class EntityDal<T>
    {
        protected readonly BookDBEntities bookDB = new BookDBEntities();

        /// <summary>
        /// Get only one entity based on ID
        /// </summary>
        /// <param name="nID">ID of entity</param>
        /// <returns>Entity</returns>
        protected internal abstract T GetSingle(int nID);

        /// <summary>
        /// Get all entity
        /// </summary>
        /// <returns>List entity</returns>
        protected internal abstract List<T> GetList();

        /// <summary>
        /// Get all entity based on name
        /// </summary>
        /// <param name="strName">Name</param>
        /// <returns>List entity</returns>
        protected internal abstract List<T> GetList(String strName);

        /// <summary>
        /// Add entity to database
        /// </summary>
        /// <param name="entity">Entity need add</param>
        /// <returns>Result of adding (success or fail)</returns>
        protected internal abstract Boolean Add(T entity);

        /// <summary>
        /// Update entity to dataabse
        /// </summary>
        /// <param name="entity">Entity</param>
        /// <returns>Result of update (success or fail)</returns>
        protected internal abstract Boolean Update(T entity);
    }
}
